package com.rt.easyjava.common.dozer;

import org.dozer.DozerBeanMapper;
import org.dozer.Mapper;
import org.dozer.spring.DozerBeanMapperFactoryBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wxy on 2020/1/14.
 */
public class DozerMapper<T1,T2> extends DozerBeanMapperFactoryBean {

    private Mapper mapper;
    DozerBeanMapper beanMapper;


    public List<T2> map(List<T1> list, Class<T2> clazz){

        List<T2> returnList = new ArrayList<>();
        for(T1 bean:list){
            if(bean==null)continue;
            T2 dto = mapper.map(bean,clazz);
            returnList.add(dto);
        }
        return returnList;
    }



    public Mapper getMapper() {
        return mapper;
    }

    public void setMapper(Mapper mapper) {
        this.mapper = mapper;
    }

}
